<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Models\Tag;
use Illuminate\Http\Request;

class TagController extends Controller
{
    //

    public function index(){
        $keyword = \request()->input('keyword','');
        $tags = Tag::when($keyword,function ($builder) use($keyword){
            $builder->where('name','like',$keyword.'%');
        })->take(10)
            ->pluck('name','id');
        return response()->json(successDataFormat($tags));
    }
}
